package net.apexes.demo.codegen.dslite.qvar;

import java.math.BigDecimal;
import net.apexes.demo.codegen.dslite.entity.Pay;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.apexes.demo.codegen.entity.enums.PayType;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QPay is a DSLite query type for Pay
 * @see Pay
 */
public class QPay extends QEntityBase<Pay> {

    public static final QPay $ = new QPay("PAY");

    public final StringColumn name = varchar("NAME", 32).field("name").notNull().build();

    public final SimpleColumn<PayType> payType = varchar(PayType.class, "PAY_TYPE", 1).field("payType").notNull().build();

    public final BooleanColumn allowChange = bool("ALLOW_CHANGE").field("allowChange").notNull().build();

    public final BooleanColumn allowFavoured = bool("ALLOW_FAVOURED").field("allowFavoured").notNull().build();

    public final NumberColumn<BigDecimal> defaultValue = decimal("DEFAULT_VALUE", 12, 3).field("defaultValue").build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index primaryKey1 = index("PRIMARY_KEY_1").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public QPay(String tableName) {
        super(Pay.class, tableName);
    }

    @Override
    public Pay newEntity() {
        return new Pay();
    }

    @Override
    public Object getFieldValue(Pay entity, String fieldName) {
        switch (fieldName) {
            case "name":
                return entity.getName();
            case "payType":
                return entity.getPayType();
            case "allowChange":
                return entity.getAllowChange();
            case "allowFavoured":
                return entity.getAllowFavoured();
            case "defaultValue":
                return entity.getDefaultValue();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(Pay entity, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                entity.setName((java.lang.String) value);
                break;
            case "payType":
                entity.setPayType((net.apexes.demo.codegen.entity.enums.PayType) value);
                break;
            case "allowChange":
                entity.setAllowChange((java.lang.Boolean) value);
                break;
            case "allowFavoured":
                entity.setAllowFavoured((java.lang.Boolean) value);
                break;
            case "defaultValue":
                entity.setDefaultValue((java.math.BigDecimal) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

